import { getTopCategoryAPI } from '@/apis/Category'
import { ref, watchEffect } from 'vue'
import { useRoute } from 'vue-router'

export function useCategory() {
  const categoryData = ref({})
  const route = useRoute()
  const getCategory = async () => {
    const res = await getTopCategoryAPI(route.params.id)
    categoryData.value = res.result
  }
  watchEffect(() => getCategory())
  return {
    categoryData,
  }
}
